<template>
  <div class="IPBOX">
    <input class="input" type="text" v-model="IP" disabled />
    <div class="btnBox">
      <button class="btn" @click="commit" v-items>确定</button>
      <button class="btn" @click="out" v-items>退格</button>
    </div>
    <div class="keyboard">
      <span
        @click="write('http://')"
        v-items="{ default: true }"
        style="width:100%;"
        >http://</span
      >
      <span
        v-for="index in 10"
        :key="index"
        @click="write(index - 1)"
        v-items
        >{{ index - 1 }}</span
      >
      <span @click="write('.')" v-items>.</span>
      <span @click="write(':')" v-items>:</span>
      <span @click="send"> send</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      IP: 'http://47.103.128.167:9191'
    };
  },
  methods: {
    out() {
      this.IP = this.IP.substring(0, this.IP.length - 1);
    },
    write(text) {
      this.IP = this.IP + text;
    },
    commit() {
      this.$store.commit('setIP', this.IP);
      if (this.$store.getters.getIP) {
        this.$router.push({
          path: '/home'
        });
      }
    },
    send() {
      this.$android.testSend();
    }
  }
};
</script>

<style lang="less" scoped>
.IPBOX {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.input {
  width: 90%;
  height: 80px;
  font-size: 30px;
}
.btnBox {
  width: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.keyboard {
  width: 80%;
  height: 50px;
  color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
}
.keyboard > span {
  padding: 4px;
  width: 28%;
  height: 100%;
  line-height: 100%;
  text-align: center;
  display: block;
  margin: 10px;
  background: #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
}
.btn {
  padding: 4px;
  width: 100px;
  height: 50px;
  background: #ccc;
  margin: 10px;
}
</style>
